package com.cn.wanxi.IO;

import com.cn.wanxi.IOModel.NavModelIO;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Arrays;

public class NavIO {
    /**
     * 将导航写入记事本
     *
     * @param path
     */
    public void writeNote(String path) {
        File file = new File(path);
        try {
            file.createNewFile();//创建记事本文件文件
            OutputStream outputStream = new FileOutputStream(file);
            NavModelIO navModelIO = new NavModelIO();
            String hrefs = Arrays.toString(navModelIO.getHrefs());
//            System.out.println(hrefs);
            outputStream.write(hrefs.getBytes());
            outputStream.write("@@".getBytes());
            String titles[] = navModelIO.getTitles();//得到IO流里面导航名字的数组
            String stringTitle = Arrays.toString(titles);//将数组转换为字符串
            byte[] bytes = stringTitle.getBytes();//将字符串转换为数组，因为写的时候参数必须是byte[]
            outputStream.write(bytes);
        } catch (IOException e) {
            e.printStackTrace();
        }


    }
}
